<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../../vue.js"></script>
</head>

<body>
  <div id="app">
    <input type="text" v-model="mes">
    <ul>
      <li v-for="item in filterPerson" :key="item.id">
        name:{{item.name}}---sex:{{item.sex}}
      </li>
    </ul>
  </div>
  <script>
    new Vue({
      el: "#app",
      data() {
        return {
          mes: "",
          person: [
            { id: 1, name: "Jay", sex: "男" },
            { id: 2, name: "JJ", sex: "男" },
            { id: 3, name: "Eson", sex: "男" },
            { id: 4, name: "Esjj", sex: "女" },
            { id: 5, name: "hello", sex: "女" },
          ],
          filterPerson: [],
        };
      },
      watch: {
        mes: {
          immediate: true,
          handler(newVal) {
            this.filterPerson = this.person.filter(item => {
              return item.name.toLowerCase().includes(newVal.toLowerCase());
            });
          }
        }
      },
    })
  </script>
</body>

</html>